package com.hoas.quickstart.threads.chapter04.chapter09_1_9;

import java.util.concurrent.locks.ReentrantLock;

public class Service {

    private ReentrantLock lock;

    public Service(boolean isFair) {
        this.lock = new ReentrantLock( isFair );
    }

    public void serviceMethod() {
        try {
            lock.lock();
            System.out.println("ThreadName=" +Thread.currentThread().getName() + " 获得锁定");
        } finally {
            lock.unlock();
        }
    }


}
